<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title>学校分组</title>
	<link rel="stylesheet" href="../css/common2.css">
	<style scoped>
		.hut_but_tz {
			display: inline-block;
			height: 38px;
			width: 108px;
			line-height: 38px;
			padding: 0 18px;
			background: url(../image/enter.png) no-repeat center center;
			color: #fff;
			white-space: nowrap;
			text-align: center;
			font-size: 14px;
			border: none;
			border-radius: 2px;
			cursor: pointer;
		}

		.search_box {
			display: flex;
			align-items: center;
		}

		.search_left {
			display: flex;
			align-items: center;
			margin-right: 30px;
		}

		.select_s {
			width: 100px;
			height: 35px;
			border: none;
			margin-right: 5px;
		}

		.search_name {
			height: 35px;
			max-width: 118px;
			padding: 0 5px;
			margin-right: 5px;
		}

		.table {
			width: 99%;
		}
		.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 400px;
    text-align: center;
}
.modal-content ul {
    list-style: none;
    padding: 0;
}
.modal-content li {
    margin: 5px 0;
    font-size: 16px;
}
button {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 14px;
    border: none;
    background: #007bff;
    color: white;
    border-radius: 4px;
    cursor: pointer;
}
button:hover {
    background: #0056b3;
}
[v-if]{
	display: none;
}
	</style>
</head>

<body class="main-body">
	<div id="vue-root" style="margin-top:50px;">
		<div v-if="showModal" class="modal">
			<div class="modal-content">
				<h3>学校分组列表</h3>
				<ul>
					<li v-for="name in matchedSchoolNames" :key="name">{{ name }}</li>
				</ul>
				<button @click="closeModal">关闭</button>
			</div>
		</div>
		<div class="search_box">
			
			<div class="add">
				<a href="school_grouping_item.html" v-if="able.add" style="color: white">添加学校分组</a>
			</div>
			<!-- <div class="refresh" onclick="location.reload()" style="display: inline-block;">刷新</div> -->
		</div>
		<div class="table ">
			<table class="table_top">
				<thead>
					<tr>
						<th class="two">
							<input type="checkbox" class="check-box">
						</th>
						<th class="two">序号</th>
						<th style="width: 50%">名称</th>
						<th class="two" style="width: 90%">查看</th>
						
						<th class="three">编辑</th>
					</tr>
				</thead>
				<tbody id="list">
					<tr v-for="(item,index) in list" :key="item.id">
						<td style="width: 100px">
							<input type="checkbox" class="check-box">
						</td>
						<td style="width: 100px"><span v-text="index+1"></span></td>
						
						<td class="four" v-text="item.name"></td>

						<td>
							<button @click="showMatchedSchools(item.schoolIds)">查看</button>
					</td>

						<td class="three" style="width: 100px">
							<div class="option">
								<div class="edit-icon option-icon" v-if="able.edit">
									<a :href="'school_grouping_item.html?id='+item.id+'&type='+item.type"
										style="position: absolute; left: 20%; top: 30%;">
										<img class="img" src="../image/edit.png" height="20" width="20"
											onmouseover="this.src='../image/edit_light.png'"
											onmouseout="this.src='../image/edit.png'" />
									</a>
								</div>
								
								<!-- <div class="delete-icon option-icon" v-if="able.del" @click="checkAndDelete(item.id)"
									style="right: 20%; top:30%;position: absolute;">
									<img class="img" src="../image/delete.png" height="20" width="20"
										onmouseover="this.src='../image/delete_light.png'"
										onmouseout="this.src='../image/delete.png'" />
								</div> -->
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</div>

		<ul class="pagination" v-if="pages>1">
			<li>
				<a v-if="pageNum!=1" @click="pageNum=1">«</a>
				<a class="pages-jump" v-if="pageNum!=1" @click="pageNum&#45;&#45;">‹</a>
				<a v-text="pageNum"></a>
				<a class="pages-jump" v-if="pageNum!=pages" @click="pageNum++">›</a>
				<a v-if="pageNum!=pages" @click="pageNum=pages">»</a>
			</li>

		</ul>
		<div style="float: right;margin-bottom: 20px;">
			总共{{total}}条记录
			<select class="ui-select init" style="height:32px" v-model="pageSize">
				<option :value="10">每页10条</option>
				<option :value="30">每页30条</option>
				<option :value="100">每页100条</option>
			</select>
		</div>

	</div>
	<script src="/scriptZIP/qs.min.js"></script>
	<script src="/scriptZIP/vue.min.js"></script>
	<script src="/scriptZIP/axios.min.js"></script>

	<script src="/js/common.js"></script>
	<script src="/js/list.js"></script>
	<script src="/js/auth_util.js"></script>

	<script>

		new Vue(merge({
			data: {
				urls: {
					list: '/pc/schoolGroup/list/' + top_params().id,
					del: '/pc/schoolGroup/del',
					// check: '/pc/auth/userCount'
				},
				schools:[],
				matchedSchoolNames: [],
    showModal: false
			},
			created () {
				abled('authorityManagement1', this);
				this.getData();
				axios.get('/pc/school/all/'+top_params().id).then(function (res) {
					this.schools = res.data;
					
				}.bind(this));
			},
			methods: {
				showMatchedSchools(schoolIds) {
            this.matchedSchoolNames = this.schools
                .filter(school => schoolIds.includes(school.id)) // 匹配 ID
                .map(school => school.name); // 提取名称
            this.showModal = true; // 打开模态弹窗
        },
        // 关闭模态弹窗
        closeModal() {
            this.showModal = false;
        },
				input() {
					if (this.search.name == '') {
						this.search = {}
					}
				},
				delMsgPopup: function (ids) {
					return localStorage.lang == 'en' ? 'confirm deletion?' : '确定删除这1项吗？';
				},
			}
		}));
	</script>


</body>

</html>